home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ Sep 89 / Y0069-Re IDType vs item n-Sep89 < prev    next >
Encoding:
Text File  |  1989-09-21  |  1.5 KB  |  47 lines  |  [TEXT/GEOL]

  1. Item    6179423                         21-Sept-89        09:07
  2.  
  3. From:   LINS                            Lins, Chuck
  4.  
  5. To:     D1165                           Esha, David C Hands,PRT
  6.  
  7. cc:     MACAPP.TECH$                    MACAPP Tech
  8.  
  9. Sub:    Re: IDType vs item number
  10.  
  11. David,
  12.  
  13. Another solution is to add a data structure mapping IDTypes to the appropriate
  14. item number. Suppose, for example, you have three radio buttons with ID Types
  15. 'Fred', 'Foo ', and 'Bar ' corresponding to radio buttons 1, 2, and 3,
  16. respectively. An abstract interface for a map abstraction could be as follows
  17. (reduced for the sake of this example):
  18.  
  19. PROCEDURE Bind (theMap : Map; theDomain : IDType; theRange : INTEGER);
  20.  
  21. FUNCTION  BoundTo (theMap : Map; theDomain : IDType) : INTEGER { range };
  22.  
  23. You would initialize the map with the statements:
  24.  
  25. Bind(myMap, 'Fred', 1);
  26. Bind(myMap, 'Foo ', 2);
  27. Bind(myMap, 'Bar ', 3);
  28.  
  29. The order of the above statements is not important.
  30.  
  31. Now when you get an IDType and need to find out which item number it is you can
  32. simply make the call:
  33.  
  34. selectedItem := BoundTo(myMap, selectedIdType);
  35.  
  36. This presumes you have an abstract data type which you've previously
  37. instaniated. If you'll have only a singl map in your program you can dispense
  38. with theMap parameter.
  39.  
  40. How you implement the map is up to you. There are several possible data
  41. structures, (e.g., hash tables) but given that the number of elements in the
  42. map will be small (i.e., < 20) a simple linear list or unordered array will do.
  43.  
  44. Chuck Lins
  45. Apple Computer, Inc.
  46.  
  47.